/**
 * 教师数据存储类编写
 */

import { classToNewList } from "@/utils/util";

export class AdminUserInfo {
  constructor(info, password, remember) {
    /**
     * @method 教师账号信息
     * @param {int}    adminUserId    用户id
     * @param {String} adminAccount   用户账号
     * @param {String} avatar         用户头像
     * @param {String} password       用户密码
     * @param {boolean} remember      是否需要记住密码
     * @param {String} token          token令牌
     */
    this.adminUserId = info.id || 0;
    this.adminAccount = info.account || "";
    this.avatar = info.avatar || "";
    this.password = password || "";
    this.remember = remember || false;
    this.token = info.token || "";
  }
}

export class CourseInfo {
  constructor(info) {
    /**
     * @method 课程列表信息
     * @param {int}     count     总条数
     * @param {int}     curPage   当前页码
     * @param {boolean} hasNext   是否有下一页
     * @param {int}     totalPage 总页数
     */
    this.count = info.count || 0;
    this.curPage = info.curPage || 0;
    this.hasNext = info.hasNext || false;
    this.totalPage = info.totalPage || 0;
    this.data = classToNewList(info.data, CourseSingle) || [];
  }
}

export class CourseSingle {
  constructor(itemInfo) {
    /**
     * @method 单个课程卡片信息
     * @param {int} id              课程ID
     * @param {String} courseName   课程名称
     * @param {String} courseDesc   课程描述
    */
    this.id = itemInfo.id || 0;
    this.courseName = itemInfo.courseName || "";
    this.courseDesc = itemInfo.courseDesc || "";
  }
}

export class EvalSingle {
  constructor(itemInfo) {
    /**
     * @method 单个题目评测信息
     * @param {int} id              课程ID
     * @param {String} courseName   课程名称
     * @param {String} courseDesc   课程描述
    */
    this.id = itemInfo.id || 0;
    this.courseName = itemInfo.courseName || "";
    this.courseDesc = itemInfo.courseDesc || "";
  }
}